package 算法.练习1;

/**
 * @author:谢君臣
 * @Date:2021/8/5-9:11
 * @version:1.0
 * @function:
 */
public class NC19 {
    public static void main(String[] args) {

    }
    public static int maxsumofSubarray (int[] arr) {
       int sum = arr[0],max = arr[0] ;
        for (int i = 1; i < arr.length; i++) {
            if (sum>0) sum = sum + arr[i];
            else sum = arr[i];
            max = Math.max(max,sum);
        }
        return max;
    }
}
